# a, b = map(int, input().split())
# gdic = {}
# for i in range(b):
#     c, d = map(int, input().split())
#     gdic[c] = d
#
# for i in range(a):
#     num = i + 1
#     mx = num
#     if num not in gdic:
#         print(mx, end=" ")
#         continue
#     cur = gdic[num]
#     while True:
#         if cur not in gdic:
#             break
#         if mx < cur:
#             mx = cur
#         cur = gdic[cur]
#     print(mx, end=" ")

a, b = map(int, input().split())
s = [[]for j in range(a)]
for i in range(b):
    c, d = map(int, input().split())
    s[c - 1] = d

for i in range(a):
    mx = i + 1
    if not s[i]:
        print(mx, end=" ")
        continue
    cur = s[i]
    while True:
        if not cur:
            break
        if mx < cur:
            mx = cur
        cur = s[cur-1]
    print(mx, end=" ")
